<html>
<head>
	<meta charset="UTF-8">
	<title>websql</title>
<script type="text/javascript">
	var db=openDatabase('mydb','1.0','testDB',5*1024*1024);
	db.transaction(function(tx){
		tx.executeSql('CREATE TABLE IF NOT EXISTS logs (id unique, name)');
		tx.executeSql('INSERT INTO logs (id,name) VALUES (1,"test1")');
		tx.executeSql('INSERT INTO logs (id,name) VALUES (2,"test2")');
	});

	db.transaction(function(tx) {
		tx.executeSql('select * from logs',[],function(tx,res){
			document.querySelector("#read").innerHTML=res.rows.item(0).name;
		});
	});

	db.transaction(function (tx) {
		tx.executeSql('DELETE FROM logs  WHERE id=1');
		msg = '<p>删除 id 为 1 的记录。</p>';
		document.querySelector('#read').innerHTML =  msg;
 	});

	db.transaction(function (tx) {
		tx.executeSql('update logs set name="uptest2" where id=2');
		msg = '<p>更新 id 为 2 的记录。</p>';
		document.querySelector('#read').innerHTML =  msg;
	});

function add(values) {
  var sql = 'INSERT INTO logs(id,name) VALUES (?,?)';
      db.transaction(function(tx) {
      　　tx.executeSql(sql, values, function(tx, rs) {
                var effectRow = rs.rowsAffected;
                console.log('影响记录条数:' + effectRow);
                effectRow && console.log('执行sql成功');
          });
    });
}
var arr=[3,"test3"];
add(arr);

</script>
</head>
<body>
	<div id="read"></div>
</body>

</html>